.\"     Title: \fBmysqld_multi\fR
.\"    Author: 
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
.\"      Date: 11/02/2006
.\"    Manual: MySQL Database System
.\"    Source: MySQL 4.1
.\"
.TH "\fBMYSQLD_MULTI\fR" "1" "11/02/2006" "MySQL 4.1" "MySQL Database System"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
mysqld_multi \- manage multiple MySQL servers
.SH "SYNOPSIS"
.HP 59
\fBmysqld_multi [\fR\fB\fIoptions\fR\fR\fB] {start|stop|report} [\fR\fB\fIGNR\fR\fR\fB[,\fR\fB\fIGNR\fR\fR\fB] ...]\fR
.SH "DESCRIPTION"
.PP
\fBmysqld_multi\fR
is designed to manage several
\fBmysqld\fR
processes that listen for connections on different Unix socket files and TCP/IP ports. It can start or stop servers, or report their current status.
.PP
\fBmysqld_multi\fR
searches for groups named
[mysqld\fIN\fR]
in
\fImy.cnf\fR
(or in the file named by the
\fB\-\-config\-file\fR
option).
\fIN\fR
can be any positive integer. This number is referred to in the following discussion as the option group number, or
\fIGNR\fR. Group numbers distinguish option groups from one another and are used as arguments to
\fBmysqld_multi\fR
to specify which servers you want to start, stop, or obtain a status report for. Options listed in these groups are the same that you would use in the
[mysqld]
group used for starting
\fBmysqld\fR. (See, for example,
Section\ 10.2.2, \(lqStarting and Stopping MySQL Automatically\(rq.) However, when using multiple servers, it is necessary that each one use its own value for options such as the Unix socket file and TCP/IP port number. For more information on which options must be unique per server in a multiple\-server environment, see
Section\ 11, \(lqRunning Multiple MySQL Servers on the Same Machine\(rq.
.PP
To invoke
\fBmysqld_multi\fR, use the following syntax:
.sp
.RS 3n
.nf
shell> \fBmysqld_multi [\fR\fB\fIoptions\fR\fR\fB] {start|stop|report} [\fR\fB\fIGNR\fR\fR\fB[,\fR\fB\fIGNR\fR\fR\fB] ...]\fR
.fi
.RE
.PP
start,
stop, and
report
indicate which operation to perform. You can perform the designated operation for a single server or multiple servers, depending on the
\fIGNR\fR
list that follows the option name. If there is no list,
\fBmysqld_multi\fR
performs the operation for all servers in the option file.
.PP
Each
\fIGNR\fR
value represents an option group number or range of group numbers. The value should be the number at the end of the group name in the option file. For example, the
\fIGNR\fR
for a group named
[mysqld17]
is
17. To specify a range of numbers, separate the first and last numbers by a dash. The
\fIGNR\fR
value
10\-13
represents groups
[mysqld10]
through
[mysqld13]. Multiple groups or group ranges can be specified on the command line, separated by commas. There must be no whitespace characters (spaces or tabs) in the
\fIGNR\fR
list; anything after a whitespace character is ignored.
.PP
This command starts a single server using option group
[mysqld17]:
.sp
.RS 3n
.nf
shell> \fBmysqld_multi start 17\fR
.fi
.RE
.PP
This command stops several servers, using option groups
[mysqld8]
and
[mysqld10]
through
[mysqld13]:
.sp
.RS 3n
.nf
shell> \fBmysqld_multi stop 8,10\-13\fR
.fi
.RE
.PP
For an example of how you might set up an option file, use this command:
.sp
.RS 3n
.nf
shell> \fBmysqld_multi \-\-example\fR
.fi
.RE
.PP
\fBmysqld_multi\fR
supports the following options:
.TP 3n
\(bu
\fB\- \-help\fR
.sp
Display a help message and exit.
.TP 3n
\(bu
\fB\-\-config\-file=\fR\fB\fIfile_name\fR\fR
.sp
Specify the name of an alternative option file. This affects where
\fBmysqld_multi\fR
looks for
[mysqld\fIN\fR]
option groups. Without this option, all options are read from the usual
\fImy.cnf\fR
file. The option does not affect where
\fBmysqld_multi\fR
reads its own options, which are always taken from the
[mysqld_multi]
group in the usual
\fImy.cnf\fR
file.
.TP 3n
\(bu
\fB\-\-example\fR
.sp
Display a sample option file.
.TP 3n
\(bu
\fB\-\-log=\fR\fB\fIfile_name\fR\fR
.sp
Specify the name of the log file. If the file exists, log output is appended to it.
.TP 3n
\(bu
\fB\-\-mysqladmin=\fR\fB\fIprog_name\fR\fR
.sp
The
\fBmysqladmin\fR
binary to be used to stop servers.
.TP 3n
\(bu
\fB\-\-mysqld=\fR\fB\fIprog_name\fR\fR
.sp
The
\fBmysqld\fR
binary to be used. Note that you can specify
\fBmysqld_safe\fR
as the value for this option also. If you use
\fBmysqld_safe\fR
to start the server, you can include the
mysqld
or
ledir
options in the corresponding
[mysqld\fIN\fR]
option group. These options indicate the name of the server that
\fBmysqld_safe\fR
should start and the pathname of the directory where the server is located. (See the descriptions for these options in
\fBmysqld_safe\fR(1).) Example:
.sp
.RS 3n
.nf
[mysqld38]
mysqld = mysqld\-max
ledir  = /opt/local/mysql/libexec
.fi
.RE
.TP 3n
\(bu
\fB\-\-no\-log\fR
.sp
Print log information to
stdout
rather than to the log file. By default, output goes to the log file.
.TP 3n
\(bu
\fB\-\-password=\fR\fB\fIpassword\fR\fR
.sp
The password of the MySQL account to use when invoking
\fBmysqladmin\fR. Note that the password value is not optional for this option, unlike for other MySQL programs.
.TP 3n
\(bu
\fB\-\-silent\fR
.sp
Silent mode; disable warnings. This option was added in MySQL 4.1.6.
.TP 3n
\(bu
\fB\-\-tcp\-ip\fR
.sp
Connect to each MySQL server via the TCP/IP port instead of the Unix socket file. (If a socket file is missing, the server might still be running, but accessible only via the TCP/IP port.) By default, connections are made using the Unix socket file. This option affects
stop
and
report
operations.
.TP 3n
\(bu
\fB\-\-user=\fR\fB\fIuser_name\fR\fR
.sp
The username of the MySQL account to use when invoking
\fBmysqladmin\fR.
.TP 3n
\(bu
\fB\-\-verbose\fR
.sp
Be more verbose. This option was added in MySQL 4.1.6.
.TP 3n
\(bu
\fB\-\-version\fR
.sp
Display version information and exit.
.sp
.RE
.PP
Some notes about
\fBmysqld_multi\fR:
.TP 3n
\(bu
\fBMost important\fR: Before using
\fBmysqld_multi\fR
be sure that you understand the meanings of the options that are passed to the
\fBmysqld\fR
servers and
\fIwhy\fR
you would want to have separate
\fBmysqld\fR
processes. Beware of the dangers of using multiple
\fBmysqld\fR
servers with the same data directory. Use separate data directories, unless you
\fIknow\fR
what you are doing. Starting multiple servers with the same data directory does
\fInot\fR
give you extra performance in a threaded system. See
Section\ 11, \(lqRunning Multiple MySQL Servers on the Same Machine\(rq.
.TP 3n
\(bu
\fBImportant\fR: Make sure that the data directory for each server is fully accessible to the Unix account that the specific
\fBmysqld\fR
process is started as.
\fIDo not\fR
use the Unix
\fIroot\fR
account for this, unless you
\fIknow\fR
what you are doing. See
Section\ 5.5, \(lqHow to Run MySQL as a Normal User\(rq.
.TP 3n
\(bu
Make sure that the MySQL account used for stopping the
\fBmysqld\fR
servers (with the
\fBmysqladmin\fR
program) has the same username and password for each server. Also, make sure that the account has the
SHUTDOWN
privilege. If the servers that you want to manage have different usernames or passwords for the administrative accounts, you might want to create an account on each server that has the same username and password. For example, you might set up a common
multi_admin
account by executing the following commands for each server:
.sp
.RS 3n
.nf
shell> \fBmysql \-u root \-S /tmp/mysql.sock \-p\fR
Enter password:
mysql> \fBGRANT SHUTDOWN ON *.*\fR
    \-> \fBTO 'multi_admin'@'localhost' IDENTIFIED BY 'multipass';\fR
.fi
.RE
See
Section\ 6.2, \(lqHow the Privilege System Works\(rq. You have to do this for each
\fBmysqld\fR
server. Change the connection parameters appropriately when connecting to each one. Note that the hostname part of the account name must allow you to connect as
multi_admin
from the host where you want to run
\fBmysqld_multi\fR.
.TP 3n
\(bu
The Unix socket file and the TCP/IP port number must be different for every
\fBmysqld\fR.
.TP 3n
\(bu
The
\fB\-\-pid\-file\fR
option is very important if you are using
\fBmysqld_safe\fR
to start
\fBmysqld\fR
(for example,
\fB\-\-mysqld=mysqld_safe\fR) Every
\fBmysqld\fR
should have its own process ID file. The advantage of using
\fBmysqld_safe\fR
instead of
\fBmysqld\fR
is that
\fBmysqld_safe\fR
monitors its
\fBmysqld\fR
process and restarts it if the process terminates due to a signal sent using
kill \-9
or for other reasons, such as a segmentation fault. Please note that the
\fBmysqld_safe\fR
script might require that you start it from a certain place. This means that you might have to change location to a certain directory before running
\fBmysqld_multi\fR. If you have problems starting, please see the
\fBmysqld_safe\fR
script. Check especially the lines:
.sp
.RS 3n
.nf
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
MY_PWD=`pwd`
# Check if we are starting this relative (for the binary release)
if test \-d $MY_PWD/data/mysql \-a \-f ./share/mysql/english/errmsg.sys \-a \\
 \-x ./bin/mysqld
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
.fi
.RE
The test performed by these lines should be successful, or you might encounter problems. See
\fBmysqld_safe\fR(1).
.TP 3n
\(bu
You might want to use the
\fB\-\-user\fR
option for
\fBmysqld\fR, but to do this you need to run the
\fBmysqld_multi\fR
script as the Unix
root
user. Having the option in the option file does not matter; you merely get a warning if you are not the superuser and the
\fBmysqld\fR
processes are started under your own Unix account.
.sp
.RE
.PP
The following example shows how you might set up an option file for use with
\fBmysqld_multi\fR. The order in which the
\fBmysqld\fR
programs are started or stopped depends on the order in which they appear in the option file. Group numbers need not form an unbroken sequence. The first and fifth
[mysqld\fIN\fR]
groups were intentionally omitted from the example to illustrate that you can have
\(lqgaps\(rq
in the option file. This gives you more flexibility.
.sp
.RS 3n
.nf
# This file should probably be in your home dir (~/.my.cnf)
# or /etc/my.cnf
# Version 2.1 by Jani Tolonen
[mysqld_multi]
mysqld     = /usr/local/bin/mysqld_safe
mysqladmin = /usr/local/bin/mysqladmin
user       = multi_admin
password   = multipass
[mysqld2]
socket     = /tmp/mysql.sock2
port       = 3307
pid\-file   = /usr/local/mysql/var2/hostname.pid2
datadir    = /usr/local/mysql/var2
language   = /usr/local/share/mysql/english
user       = john
[mysqld3]
socket     = /tmp/mysql.sock3
port       = 3308
pid\-file   = /usr/local/mysql/var3/hostname.pid3
datadir    = /usr/local/mysql/var3
language   = /usr/local/share/mysql/swedish
user       = monty
[mysqld4]
socket     = /tmp/mysql.sock4
port       = 3309
pid\-file   = /usr/local/mysql/var4/hostname.pid4
datadir    = /usr/local/mysql/var4
language   = /usr/local/share/mysql/estonia
user       = tonu
[mysqld6]
socket     = /tmp/mysql.sock6
port       = 3311
pid\-file   = /usr/local/mysql/var6/hostname.pid6
datadir    = /usr/local/mysql/var6
language   = /usr/local/share/mysql/japanese
user       = jani
.fi
.RE
.PP
See
Section\ 3.2, \(lqUsing Option Files\(rq.
.SH "COPYRIGHT"
.PP
Copyright 1997\-2006 MySQL AB
.PP
This documentation is NOT distributed under a GPL license. Use of this documentation is subject to the following terms: You may create a printed copy of this documentation solely for your own personal use. Conversion to other formats is allowed as long as the actual content is not altered or edited in any way. You shall not publish or distribute this documentation in any form or on any media, except if you distribute the documentation in a manner similar to how MySQL disseminates it (that is, electronically for download on a Web site with the software) or on a CD\-ROM or similar medium, provided however that the documentation is disseminated together with the software on the same medium. Any other use, such as any dissemination of printed copies or use of this documentation, in whole or in part, in another publication, requires the prior written consent from an authorized representative of MySQL AB. MySQL AB reserves any and all rights to this documentation not expressly granted above.
.PP
Please email
<docs@mysql.com>
for more information.
.SH "SEE ALSO"
isamchk(1),
isamlog(1),
msql2mysql(1),
myisam_ftdump(1),
myisamchk(1),
myisamlog(1),
myisampack(1),
mysql(1),
mysql.server(1),
mysql_config(1),
mysql_explain_log(1),
mysql_fix_privilege_tables(1),
mysql_zap(1),
mysqlaccess(1),
mysqladmin(1),
mysqlbinlog(1),
mysqlcheck(1),
mysqld(1),
mysqld(8),
mysqld_safe(1),
mysqldump(1),
mysqlhotcopy(1),
mysqlimport(1),
mysqlshow(1),
pack_isam(1),
perror(1),
replace(1),
safe_mysqld(1)
.P
For more information, please refer to the MySQL Reference Manual,
which may already be installed locally and which is also available
online at http://dev.mysql.com/doc/.
.SH AUTHOR
MySQL AB (http://www.mysql.com/).
This software comes with no warranty.
